import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'varAnalysisM',

  state: {},

  effects: {
    //获取var损益分布图数据
    *queryGainsAndLosses({ payload, callback }, { call, put }) {
      const response = yield call(api.varAnalysis.queryGainsAndLosses, payload);
      if (response && response.code == 0) {
        callback(response.data);
      } else {
        callback();
        message.error(response && response.msg ? response.msg : '查询损益图失败!');
      }
    },

    //获取明细表数据
    *queryDetailed({ payload, callback }, { call, put }) {
      const response = yield call(api.varAnalysis.queryDetailed, payload);
      if (response && response.code == 0) {
        callback(response.data);
      } else {
        callback();
        message.error(response && response.msg ? response.msg : '查询明细表失败!');
      }
    },

    //获取结果表数据
    *queryresultCharts({ payload, callback }, { call, put }) {
      const response = yield call(api.varAnalysis.queryresultCharts, payload);
      if (response && response.code == 0) {
        callback(response.data);
      } else {
        callback();
        message.error(response && response.msg ? response.msg : '查询结果表失败!');
      }
    },

    reducers: {
      save(state, { payload }) {
        return {
          ...state,
          ...payload,
        };
      },
    },
  },
};
